// pages/integral/integral.js
const app = getApp();
var utils = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bg:{img:'/images/pic/j_1.png'},
    icon: { img: '/images/pic/j_2.png' },
    code:{code:520},

    tabSelect: {
      select: 0,
      jfSelect: false,
      jfup: false,
      xlSelec: false,
      xlup: false,
      img: '/images/integral/arrow_down.png',
      activeImg: '/images/integral/arrow_up.png'
    },

    goods: []


  },

  //点击tab
  tabClick(e) {
    // console.log(e.currentTarget.dataset.num)
    var that = this;
    this.setData({
      'tabSelect.select': e.currentTarget.dataset.num
    })
    if (e.currentTarget.dataset.num == 1) {
      this.setData({
        'tabSelect.jfSelect': true,
        'tabSelect.jfup': !this.data.tabSelect.jfup,
        'tabSelect.xlup': false,
        'tabSelect.xlSelect': false
      })
      var data = { openid: app.d.openid, jf: that.data.tabSelect.jfup}
    } else if (e.currentTarget.dataset.num == 2) {
      this.setData({
        'tabSelect.jfSelect': false,
        'tabSelect.xlSelect': true,
        'tabSelect.xlup': !this.data.tabSelect.xlup,
        'tabSelect.jfup': false,
      })
      var data = { openid: app.d.openid, xl: that.data.tabSelect.xlup }
    } else {
      this.setData({
        'tabSelect.jfSelect': false,
        'tabSelect.xlSelect': false,
        'tabSelect.xlup': false,
        'tabSelect.jfup': false,
      })
    }
    console.log(that.data.tabSelect);
    var sucFunc = function (that, res) {
      that.setData({
        goods: res.data.res,
        head: res.data.people
      })
      wx.hideLoading();
    }
    utils.wxRequest(that, app.d.path, "Integral/index", data, sucFunc);
    var jf = that.data.tabSelect.jfup
  },
  onLoad: function (options) {
    var that = this
    wx.showLoading({
      title: '加载中',
    })
    that.setData({
      imgPath: app.d.imgPath
    })
    var sucFunc = function (that, res) {
      that.setData({
        goods: res.data.res,
        head:res.data.people
      })
      wx.hideLoading();
    }
    var data = { openid:app.d.openid }
    utils.wxRequest(that, app.d.path, "Integral/index", data, sucFunc);
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  mingxi: function (e) {
    wx.navigateTo({
      url: "/pages/jifenDetail/jifenDetail"
    })
  },
  duihuan: function (e) {
    wx.navigateTo({
      url: "/pages/coupon/coupon"
    })
  },

  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})